/*! \file SimpleApp.cpp
 *	\brief 
 *
 *	created:	2009/11/10
 *	created:	10:11:2009   16:56
 *	filename: 	c:\src\main\libs\app\SimpleApp.cpp
 *	file path:	c:\src\main\libs\app
 *	file base:	SimpleApp
 *	file ext:	cpp
 *	author:		Vitalii Trubchaninov
 *				venngraydog@gmail.com
 */
 
#include "app/stdafx.h"
#include "SimpleApp.h"

#include <app/AppFactory.h>
#include <app/Window.h>
#include <config/BaseConfig.h>
#include <core/exception.h>

namespace tt{
namespace app{

SimpleApp::SimpleApp()
: Base()
, m_Window()
{
}

SimpleApp::~SimpleApp(void)
{
}

const SharedPtr<Window>& SimpleApp::GetWindow() const
{
	return m_Window;
}

void SimpleApp::onCreate()
{
	createWindow();
}

void SimpleApp::onRun()
{
	m_Window->show(WST_SHOW);
	// Main message loop:
	for(;;)
	{
		if(!m_Window->update())
			break;
		onUpdate();
	}

	//return (int) msg.wParam;
}

void SimpleApp::onUpdate()
{
	
}

void SimpleApp::onDestroy()
{
	m_Window.reset();
}

void SimpleApp::SetWindow( const SharedPtr<Window>& window )
{
	m_Window = window;
}

void SimpleApp::createWindow()
{
	if (m_Window)
		return;

	SharedPtr<Window> window = ttAppFactory().createWindow();
	//window->setFullscreen(true);
	window->create( WindowBounds(0, 0, 1280, 720) );

	SetWindow(window);
}

} //namespace app
} //namespace tt
